//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<GameDebug.h>
///	@path	~/src/appear/xwin/
///	@date	2007/11/12
///	@desc	Game debug integration.

#pragma once

#include "xeres.h"

#include "lib/utilities/dict.h"

#include "appear/app/input_handler.h"
#include "appear/app/ticker.h"
#include "appear/app/console.h"

namespace xeres {

	/*!
		\class	GameDebug
		\brief	Integrate activities, statistics & observers.
	*/
	class GameDebug : public Ticker , public InputHandler
	{
	public:

		/// \ctor
		GameDebug( void );

		/// \dtor
		virtual ~GameDebug( void );

	//@ interface

		/*!
			\brief		Initialize debugger.
		*/
		void Initialize( void );

		/*!
			\brief		Finalize debugger.
		*/
		void Finalize( void );

		/*!
			\brief		Tick update call.
		*/
		virtual void Tick( Engine& engine );

		/*!
			\brief		Filter messages,
						return true to stop next level,
						otherwise engine will search next filter.
		*/
		virtual bool Filter( HWND hWnd , UINT message , WPARAM wParam , LPARAM lParam );

		/*!
			\brief		Process key input message.
		*/
		virtual HandleInput OnKeyInput( const KeyInput& input );

		/*!
			\brief		Process mouse input message.
		*/
		virtual HandleInput OnMouseInput( const MouseInput& input );

		/*!
			\brief		Render debug elements.
		*/
		void Render( RenderContext& rc );

		/*!
			\brief		Register debug console.
						Notice the console will be deleted by debugger.
		*/
		bool RegisterConsole( const WString& name , Console * console );

		/*!
			\brief		Active specific console, pass empty to hide console.
		*/
		void ActiveConsole( const WString& name );

		/*! 
			\brief		Get active console.
		*/
		Console * GetActiveConsole( void );

	private:

	//@ data

		// mapping shell
		dict< WString , Console * >		m_consoles;
		// actived console
		Console *						m_activedConsole;
	};

} // namespace xeres
